package com.ss.android.newmedia.activity;

import android.content.res.Resources;
import android.os.Bundle;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ProgressBar;
import android.widget.TextView;

import com.ss.android.article.browser.R;
import com.ss.android.common.ui.view.SwipeOverlayFrameLayout;
import com.ss.android.j.b;

public class FragmentActivity extends BaseActivity {
    public static final int BACK_ANIMATION_ACTIVITY = 0;
    public static final int BACK_ANIMATION_DEFAULT = 0;
    public static final int BACK_ANIMATION_VIEW = 1;
    public static final int ORIENTATION_AUTO = 0;
    public static final int ORIENTATION_DEFAULT = 0;
    public static final int ORIENTATION_LANDSCAPE = 2;
    public static final int ORIENTATION_PORTRAIT = 1;
    protected static final int THEME_MODE_DAYNIGHT = 0;
    protected static final int THEME_MODE_NONE = 1;
    protected static final int THEME_MODE_OVERLAY = 2;
    public TextView mBackBtn;
    private boolean mFinishAnimating = false;
    public boolean mIsNightMode = false;
    public View mNightModeOverlay;
    public TextView mRightBtn;
    public ProgressBar mRightProgress;
    public View mRootView;
    public SwipeOverlayFrameLayout mSwipeOverlay;
    public ViewGroup mTitleBar;
    public TextView mTitleView;

    public int getDayBackgroundRes() {
        return R.color.default_window_bg;
    }

    public int getLayout() {
        return R.layout.fragment_activity;
    }

    public int getNightBackgroundRes() {
        return R.color.default_window_bg_night;
    }

    public void hideTitleBar() {
        if (this.mTitleBar != null) {
            this.mTitleBar.setVisibility(View.GONE);
        }
    }

    public void init() {
        this.mRootView = this.findViewById(com.ss.android.article.browser.R.id.root_view);
        this.mTitleBar = (ViewGroup) this.findViewById(R.id.title_bar);
        this.mNightModeOverlay = this.findViewById(com.ss.android.article.browser.R.id.night_mode_overlay);
        if (this.mTitleBar != null) {
            this.mBackBtn = this.mTitleBar.findViewById(com.ss.android.article.browser.R.id.back);
            this.mRightBtn = this.mTitleBar.findViewById(com.ss.android.article.browser.R.id.right_text);
            this.mTitleView = this.mTitleBar.findViewById(com.ss.android.article.browser.R.id.title);
            this.mRightProgress = this.mTitleBar.findViewById(com.ss.android.article.browser.R.id.right_progress);
        }

        if (this.mBackBtn != null) {
            this.mBackBtn.setOnClickListener(new s(this));
        }

        View v0 = this.findViewById(com.ss.android.article.browser.R.id.swipe_overlay);
        if (v0 != null && ((v0 instanceof SwipeOverlayFrameLayout))) {
            this.mSwipeOverlay = ((SwipeOverlayFrameLayout) v0);
        }

        if ((this.useSwipe()) && this.mSwipeOverlay != null) {
            this.mSwipeOverlay.setOnSwipeListener(new t(this));
        }
    }

    public void onBackBtnClick() {
        this.onBackPressed();
    }

    public void onCreate(Bundle savedInstanceState) {
        this.onCreateHook();
        super.onCreate(savedInstanceState);
        try {
            this.setContentView(this.getLayout());
        } catch (Resources.NotFoundException e) {
            e.printStackTrace();
            this.finish();
            return;
        }
        this.init();
    }

    public void onCreateHook() {
        this.supportRequestWindowFeature(10);
    }

    public void onResume() {
        super.onResume();
        this.tryRefreshTheme();
    }

    public void setTitle(CharSequence title) {
        if (this.mTitleView != null) {
            this.mTitleView.setText(title);
        }
    }

    public void showTitleBar() {
        if (this.mTitleBar != null) {
            this.mTitleBar.setVisibility(View.VISIBLE);
        }
    }

    protected void tryRefreshTheme() {
        b.isNightModeToggled();
        if (this.mIsNightMode) {
            this.mIsNightMode = false;
        }
    }

    public boolean useSwipe() {
        return true;
    }

    public boolean useSwipeRight() {
        return true;
    }

    public boolean userSwipeLeft() {
        return true;
    }
}

